<TeXmacs|2.1.1>

<style|<tuple|generic|chinese|framed-session|python>>

<\body>
  <\session|python|default>
    <\output>
      Python 3.11.0 [c:\\python311\\python.exe]\ 

      Python plugin for TeXmacs.

      Please see the documentation in Help -\<gtr\> Plugins -\<gtr\> Python
    </output>

    <\input>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|input>
      import math
    </input>

    <\input>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|input>
      s=[x for x in range(100)]
    </input>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      s
    <|unfolded-io>
      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
      20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
      38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
      56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
      74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
      92, 93, 94, 95, 96, 97, 98, 99]
    </unfolded-io>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      m,n=31,7;[[i for i in range(m) if (i+j) % n==0] for j in range(n)]
    <|unfolded-io>
      [[0, 7, 14, 21, 28], [6, 13, 20, 27], [5, 12, 19, 26], [4, 11, 18, 25],
      [3, 10, 17, 24], [2, 9, 16, 23, 30], [1, 8, 15, 22, 29]]
    </unfolded-io>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      m,n=31,7;[[i for i in range(m) if (i+j) % n ==0] for j in range(n)]
    <|unfolded-io>
      [[0, 7, 14, 21, 28], [6, 13, 20, 27], [5, 12, 19, 26], [4, 11, 18, 25],
      [3, 10, 17, 24], [2, 9, 16, 23, 30], [1, 8, 15, 22, 29]]
    </unfolded-io>

    <\input>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|input>
      import csv
    </input>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      with open(r'C:\\Users\\zhang\\test.txt', newline='') as csvfile:

      \ \ \ \ dialect = csv.Sniffer().sniff(csvfile.read(1024*1024))

      \ \ \ \ csvfile.seek(0)

      \ \ \ \ reader = csv.reader(csvfile, dialect)

      \ \ \ \ # ... process CSV file contents here ...<text|>

      \ \ \ \ for row in reader:

      \ \ \ \ \ \ \ \ print(row)

      \ \ \ \ print(reader.line_num)
    <|unfolded-io>
      \;
    </unfolded-io>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      file_path = r'C:\\Users\\zhang\\test.txt' \ 

      n = 7

      with open(file_path, "r") as file:

      \ \ \ \ lines = file.readlines()

      \ \ \ \ lines = [line.strip() for line in lines]

      \ \ \ \ m = len(lines);

      \ \ \ \ print([[lines[i]\ 

      \ \ \ \ \ \ \ \ \ \ \ \ for i in range(m) if (i+j) % n ==0]\ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ for j in range(n)])

      \ \ \ \ for j in range(n):

      \ \ \ \ \ \ \ \ for i in range(m):

      \ \ \ \ \ \ \ \ \ \ \ \ if (i+j) % n == 0:

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ print(lines[i])

      \ \ \ \ \ \ \ \ 

      #print(lines)

      \;

      \;
    <|unfolded-io>
      [['0,', '7,', '14,', '21,', '28,'], ['6,', '13,', '20,', '27,'], ['5,',
      '12,', '19,', '26,'], ['4,', '11,', '18,', '25,'], ['3,', '10,', '17,',
      '24,', ''], ['2,', '9,', '16,', '23,', '30,'], ['1,', '8,', '15,',
      '22,', '29,']]

      0,

      7,

      14,

      21,

      28,

      6,

      13,

      20,

      27,

      5,

      12,

      19,

      26,

      4,

      11,

      18,

      25,

      3,

      10,

      17,

      24,

      \;

      2,

      9,

      16,

      23,

      30,

      1,

      8,

      15,

      22,

      29,
    </unfolded-io>

    <\textput>
      \;
    </textput>

    <\unfolded-io>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|unfolded-io>
      import os

      work_dir = r'C:\\path\\to\\work\\dir'

      file_name = r'input.txt' \ 

      n = 7

      \;

      os.chdir(work_dir)

      \;

      with open(file_name, "r") as file:

      \ \ \ \ lines = file.readlines()

      \ \ \ \ lines = [line.strip() for line in lines]

      \ \ \ \ m = len(lines);

      \;

      \ \ \ \ for j in range(n):

      \ \ \ \ \ \ \ \ with open(os.path.join(work_dir, str(j)+'.txt'), "w")
      as ofile:

      \ \ \ \ \ \ \ \ \ \ \ \ for i in range(m):

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if (i+j) % n == 0:

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ print(lines[i])

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ofile.write(lines[i]+'\\n')

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
    <|unfolded-io>
      0,

      7,

      14,

      21,

      28,

      6,

      13,

      20,

      27,

      5,

      12,

      19,

      26,

      4,

      11,

      18,

      25,

      3,

      10,

      17,

      24,

      \;

      2,

      9,

      16,

      23,

      30,

      1,

      8,

      15,

      22,

      29,
    </unfolded-io>

    <\input>
      \<gtr\>\<gtr\>\<gtr\>\ 
    <|input>
      \;
    </input>
  </session>
</body>

<\initial>
  <\collection>
    <associate|indent-indentation|1tab>
    <associate|page-medium|paper>
  </collection>
</initial>